import Vue from 'vue';
import VueRouter from 'vue-router';

import IndexView from './index'
import MessageView from './message'
import NotifyView from './notify'


import ProjectView from './project'
import ProjectCreateView from './project_create'
import ProjectDetailView from './project_detail'
import ProjectEditView from './project_edit'
import ProjectAnchorView from './project_anchor'
import ReportView from './report'
import ReportEmailView from './report_send_mail'
import ReportScheduleEditView from './report_schedule_edit'

import UserView from './user'
import UserEditView from './user_edit'
import UserInfoView from './user_view'

import PostMessageView from './post_message'


import NotFoundView from './404'
import NotAllowView from './403'


import ConfigView from './config'

import AnchorView from './anchor'
import AnchorInfoView from './anchor_info'
import AnchorEditView from './anchor_edit'
import AnchorBulkCreateView from './anchor_bulk_create'

import ProposalView from './proposal'

import MyAccountView from './myAccount'

import IresearchView from './iresearch'

import PlatformEditView from './platform'

import SystemView from './system'
import EventView from './event'

Vue.use(VueRouter);

const router = new VueRouter({
    mode: 'history',
    base: '/',
    routes: [
        {path: '/', component: IndexView, meta: {title: '首页'}},
        {path: '/system', component: SystemView, meta: {title: '系统状态'}},
        {path: '/event', component: EventView, meta: {title: '用户操作记录'}},

        {path: '/my', component: MyAccountView, meta: {title: '我的账号'}},
        {path: '/message', component: MessageView, meta: {title: '所有短消息'}},
        {path: '/notify', component: NotifyView, meta: {title: '所有通知'}},
        {path: '/new_message', component: PostMessageView, meta: {title: '发送短消息'}},
        {path: '/new_notify', component: PostMessageView, meta: {title: '发新通知'}},

        {path: '/project', component: ProjectView, meta: {title: '项目列表'}},
        {path: '/project/create', component: ProjectCreateView, meta: {title: '新建项目'}},
        {name: 'project', path: '/project/:id', component: ProjectDetailView, meta: {title: '浏览项目'}},
        {path: '/project/:id/edit', component: ProjectEditView, meta: {title: '编辑项目'}},

        {path: '/project/:id/report/:date', component: ReportView, meta: {title: '浏览日志'}},
        {path: '/project/:id/report/:date/preview', component: ReportEmailView, meta: {title: '预览日志邮件'}},
        {path: '/project/:id/anchor/:anchor_id', component: ProjectAnchorView, meta: {title: '主播直播截图设置'}},
        {
            name: 'schedule',
            path: '/project/:project_id/anchor/:anchor_id/schedule/:schedule_id',
            component: ReportScheduleEditView,
            meta: {title: '直播信息设置'}
        },

        {path: '/user', component: UserView, meta: {title: '用户列表'}},
        {path: '/user/:id/edit', component: UserEditView, meta: {title: '编辑用户'}},
        {path: '/user/create', component: UserEditView, meta: {title: '创建用户账号'}},
        // {path: '/user/info/:id', component: UserInfoView, meta: {title: '用户信息'}},

        {path: '/anchor', component: AnchorView, meta: {title: '主播列表'}},
        {path: '/anchor/bulk-create', component: AnchorBulkCreateView, meta: {title: '批量创建主播'}},
        {path: '/anchor/create', component: AnchorEditView, meta: {title: '创建主播'}},
        {path: '/anchor/:id', component: AnchorInfoView, meta: {title: '主播信息'}},
        {path: '/anchor/:id/edit', component: AnchorEditView, meta: {title: '编辑主播信息'}},

        {path: '/platform', component: PlatformEditView, meta: {title: '编辑平台'}},


        {path: '/proposal', component: ProposalView, meta: {title: '方案管理'}},

        {path: '/iresearch', component: IresearchView, meta: {title: '全平台数据'}},

        {path: '/view/user/:id'},
        {path: '/view/anchor/:id'},


        {path: '/config', component: ConfigView, meta: {title: '系统设置'}},
        {path: '/403', component: NotAllowView, meta: {title: '权限不足'}},
        {path: '*', component: NotFoundView, meta: {title: '不存在的页面'}}
    ]
});


if (!EASY_ENV_IS_NODE) {
    router.afterEach(to => {
        document.title = '控制台 - ' + to.meta.title;
    });
}

export default router;